﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using MySql.Data.MySqlClient;
using System.Data;

namespace ProjectBuilder
{
    [DbTable("builds")]
    public class Build
    {
        [DbField("id")]
        public long? Id { get; private set; }

        [DbField("project_id")]
        public long? ProjectId { get; set; }

        [DbField("revision")]
        public long? Revision { get; set; }

        public void Save()
        {
            var cmd = new MySqlCommand();
            cmd.CommandText = "INSERT INTO `" + this.getAttribute<DbTableAttribute>().TableName + "` (`project_id`,`revision`) VALUES ('" + ProjectId + "','" + Revision + "')";
            cmd.CommandType = CommandType.Text;
            cmd.Connection = Globals.Connection;
            cmd.ExecuteNonQuery();
            Id = cmd.LastInsertedId;
        }
    }
}